package hc.bre.script

import hc.bre.ComponentConfig
import hc.bre.cmn.ListOption
import hc.bre.cmn.RuleScriptBuilder
import hc.bre.cmn.RuleDefinition

@groovy.transform.CompileStatic
@groovy.transform.ToString
class ClosureDefinition extends RuleDefinition {
	public static final ComponentConfig _config ;
	static {
		_config = new ComponentConfig();
		_config.rtype = 'rule:script';
		_config.rname = '脚本代码';
		_config.builderClass = ClosureBuilder;
		_config.resultStruct = new hc.bre.script.ClosureResultStruct();
		_config.objectpage = '/rule/script/closurehome.htm?rpath=${rpath}';
		_config.description = '''
脚本是一种灵活的决策机制，用户几乎可以实现任何逻辑。但脚本的使用起来是比较复杂，需要一定的专业知识，建议其它决策对象不能支持时再使用。
''';
	};


	String script='';
	List<ImportItem> imports =[]

	@Override
	public ClosureDefinition load(Map map) {
		super.load(map);

		script = map['script']?:"";
		imports = hc.Util.loadList(map['imports'], ImportItem.class)

		return this;
	}

//	@Override
//	public <T extends RuleScriptBuilder> Class<T> scriptBuilderClass() {
//		return ClosureBuilder.class;
//	}
}
